package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OmDutyAccept;
import com.ruoyi.system.service.IOmDutyAcceptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 接受任务Controller
 * 
 * @author ruoyi
 * @date 2023-11-25
 */
@RestController
@RequestMapping("/system/accept")
public class OmDutyAcceptController extends BaseController
{
    @Autowired
    private IOmDutyAcceptService omDutyAcceptService;

    /**
     * 查询接受任务列表
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmDutyAccept omDutyAccept)
    {
        startPage();
        List<OmDutyAccept> list = omDutyAcceptService.selectOmDutyAcceptList(omDutyAccept);
        return getDataTable(list);
    }

    /**
     * 查询接受任务列表
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:list')")
    @GetMapping("/listByDuty")
    public List<OmDutyAccept> listByDuty(OmDutyAccept omDutyAccept)
    {
        List<OmDutyAccept> list = omDutyAcceptService.selectOmDutyAcceptList(omDutyAccept);
        return list;
    }
    /**
     * 导出接受任务列表
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:export')")
    @Log(title = "接受任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OmDutyAccept omDutyAccept)
    {
        List<OmDutyAccept> list = omDutyAcceptService.selectOmDutyAcceptList(omDutyAccept);
        ExcelUtil<OmDutyAccept> util = new ExcelUtil<OmDutyAccept>(OmDutyAccept.class);
        util.exportExcel(response, list, "接受任务数据");
    }

    /**
     * 获取接受任务详细信息
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(omDutyAcceptService.selectOmDutyAcceptById(id));
    }

    /**
     * 新增接受任务
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:add')")
    @Log(title = "接受任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmDutyAccept omDutyAccept)
    {
        return toAjax(omDutyAcceptService.insertOmDutyAccept(omDutyAccept));
    }

    /**
     * 修改接受任务
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:edit')")
    @Log(title = "接受任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmDutyAccept omDutyAccept)
    {
        return toAjax(omDutyAcceptService.updateOmDutyAccept(omDutyAccept));
    }

    /**
     * 删除接受任务
     */
   //  @PreAuthorize("@ss.hasPermi('system:accept:remove')")
    @Log(title = "接受任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(omDutyAcceptService.deleteOmDutyAcceptByIds(ids));
    }
}
